package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.Workspace.WorkspaceService;
import com.sky.vo.BusinessVO;
import com.sky.vo.OverViewDishesVO;
import com.sky.vo.OverViewOrdersVO;
import com.sky.vo.OverViewSetmealsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @Author 褚金龙
 * @Date 2024/10/18 12:20
 */

@RestController
@RequestMapping("/admin/workspace")
@CrossOrigin("*")
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkspaceController {
   @Autowired
   private WorkspaceService workspaceService;

    @ApiOperation("今日数据")
    @GetMapping("/business")
    public Result<BusinessVO> todayData(){
        LocalDateTime beginTime=LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime endTime=LocalDateTime.now().with(LocalTime.MAX);
       BusinessVO business= workspaceService.getTodayData(beginTime,endTime);
        return Result.success(business);
  }





    @ApiOperation("订单管理")
    @GetMapping("/overviewOrders")
    public Result<OverViewOrdersVO> overviewOrders(){
        OverViewOrdersVO overviewOrders= workspaceService.getOverviewOrders();
        return Result.success(overviewOrders);
    }

    @ApiOperation("菜品总览")
    @GetMapping("/overviewDishes")
    public Result<OverViewDishesVO> overviewDishes(){
        OverViewDishesVO overviewDishes= workspaceService.getOverviewDishes();
        return Result.success(overviewDishes);
    }

    @ApiOperation("套餐总览")
    @GetMapping("/overviewSetmeals")
    public Result<OverViewSetmealsVO> overviewSetmeals(){
        OverViewSetmealsVO overviewSetmeals= workspaceService.getOverviewSetmeals();
        return Result.success(overviewSetmeals);
    }

}
